package com.xuxu.blog.exception;

import com.xuxu.common.utils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @className: GlobalExceptionHandler
 * @author: Maxuxu
 * @date: 2022/8/25 23:55
 * @description: 全局异常捕捉
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public R handle(ServiceException se){
        return R.error(se.getCode(),se.getMessage());
    }
}
